<?php
declare(strict_types=1);

namespace app\common\lib;

class Str
{
    /**
     * 生成登录所需 token
     *
     * @param string $string
     * @return string
     */
    public static function getLoginToken(string $string)
    {
        $str = md5(uniqid(md5((string) microtime(true)), true));
        $token = sha1($str.$string);
        return $token;
    }

    /**
     * 根据机器号获取订单编码
     *
     * @return int
     * @throws \Exception
     */
    public static function getWorkOrderId()
    {
        $workId = env('workid');
        return SnowFlake::getInstance()->setWorkId($workId)->id();
    }
}